package com.zymail.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zymail.bean.ZyClass;
import com.zymail.bean.ZyGood;
import com.zymail.bean.ZyOrder;
import com.zymail.service.ZyClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/class")
public class ClassController extends BaseController{
    @Autowired
    private ZyClassService classService;

    /**
     * 得到所有订单的排序好之后的列表
     * @return
     */
    @GetMapping("/get")
    public List<ZyClass> getAllClass(){
        return classService.getSortedClass();
    }


    @RequestMapping("/all")
    public Map<String,Object> getAlllist(){
        Map<String,Object> map = new HashMap<>();
        List<ZyClass> data = classService.list();
        map.put("code",0);
        map.put("data",data);
        return map;
    }

    @RequestMapping("/del")
    public String del(ZyClass zyClass){
        classService.removeById(zyClass.getId());
        return "succ";
    }


    @RequestMapping("/save")
    public String save(ZyClass zyClass){
        classService.saveOrUpdate(zyClass);
        return "succ";
    }


}
